// pages/fy/fy.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // 下拉框
        select: false,
        grade_name: '*请选择*',
        grades: ['全部 ', '挂号成功', '停诊关闭', '已取消','挂号订单处理中'],
        arr:['.v1','.v2','.v3','.v4','.v5','.v6'],
      // tab切换  
      currentTab:-1,
      swiperViewHeight: '',
      listData0:[
        {"zt":"1","sj":"2021-11-28","ks":"内分泌","jzr":"肖雨婷","mo":"挂号成功"},
        {"zt":"1","sj":"2021-12-28","ks":"口腔科","jzr":"谢文婷","mo":"挂号成功"},
        {"zt":"1","sj":"2022-1-28","ks":"骨科","jzr":"肖雨婷","mo":"挂号成功"},
        {"zt":"2","sj":"2022-1-28","ks":"骨科","jzr":"肖雨婷","mo":"停诊关闭"},
        {"zt":"2","sj":"2022-1-28","ks":"外科","jzr":"肖雨婷","mo":"停诊关闭"},
        {"zt":"3","sj":"2022-1-28","ks":"内科","jzr":"肖雨婷","mo":"已取消"},
        {"zt":"4","sj":"2022-1-28","ks":"呼吸科","jzr":"肖雨婷","mo":"挂号订单处理中"},
        {"zt":"1","sj":"2021-11-28","ks":"内分泌","jzr":"肖雨婷","mo":"挂号成功"},
        {"zt":"1","sj":"2021-12-28","ks":"口腔科","jzr":"谢文婷","mo":"挂号成功"},
        {"zt":"1","sj":"2022-1-28","ks":"骨科","jzr":"肖雨婷","mo":"挂号成功"},
        {"zt":"2","sj":"2022-1-28","ks":"骨科","jzr":"肖雨婷","mo":"停诊关闭"},
        {"zt":"2","sj":"2022-1-28","ks":"外科","jzr":"肖雨婷","mo":"停诊关闭"},
        {"zt":"3","sj":"2022-1-28","ks":"内科","jzr":"肖雨婷","mo":"已取消"},
        {"zt":"4","sj":"2022-1-28","ks":"呼吸科","jzr":"肖雨婷","mo":"挂号订单处理中"},
        {"zt":"1","sj":"2021-11-28","ks":"内分泌","jzr":"肖雨婷","mo":"挂号成功"},
        {"zt":"1","sj":"2021-12-28","ks":"口腔科","jzr":"谢文婷","mo":"挂号成功"},
        {"zt":"1","sj":"2022-1-28","ks":"骨科","jzr":"肖雨婷","mo":"挂号成功"},
        {"zt":"2","sj":"2022-1-28","ks":"骨科","jzr":"肖雨婷","mo":"停诊关闭"},
        {"zt":"2","sj":"2022-1-28","ks":"外科","jzr":"肖雨婷","mo":"停诊关闭"},
        {"zt":"3","sj":"2022-1-28","ks":"内科","jzr":"肖雨婷","mo":"已取消"},
        {"zt":"4","sj":"2022-1-28","ks":"呼吸科","jzr":"肖雨婷","mo":"挂号订单处理中"},
      ],
      listData:[]
    },
    bindShowMsg() {
        this.setData({
          select: !this.data.select
        })
      },
      mySelect(e) {
        console.log(e)
        var name = e.currentTarget.dataset.name
        this.setData({
          grade_name: name,
          select: false
        })
      },
    // 点击tab切换 
    swichNav: function (e) {
    // 点击tab跳转
      var that = this;
      if (this.data.currentTab === e.target.dataset.current) {
        return false;
      } else {
        that.setData({
          currentTab: e.target.dataset.current
        })
      }
    // 点击关闭下拉框
      console.log(e)
        var name = e.currentTarget.dataset.name
        this.setData({
          grade_name: name,
          select: false
        })
        this.setSwiperHeight(this.data.arr[0])
        //显示
        // 
        // 
        // 
        var currents = e.currentTarget.dataset.current;
        var listData = [];
        for (const element of this.data.listData0){
          if(currents == 0 ){
            listData.push(element)
          }
          else if(element.zt == currents ){
            listData.push(element)
          }
        }
        console.log(listData)
        this.setData({
          listData: listData,
        })
    },
    
    // 赋值高度
    setSwiperHeight: function (v) {
      let query = wx.createSelectorQuery().in(this);
      query.select(v).boundingClientRect();
      query.exec((res) => {
        let headerHeight = res[0].height;
        this.setData({
          swiperViewHeight: headerHeight
        });
      });
    },
      // swiper 自适应高度
      onLoad: function (options) {
          this.setSwiperHeight(this.data.arr[0])
        },
        
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
  
    },
  
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
  
    },
  
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
  
    },
  
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
  
    },
  
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
  
    },
  })
  